package com.lwisn.demo.logic;

import java.nio.charset.Charset;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.lwisn.demo.filesystem.dao.EncodingDao;

public class FileEncoderUnicode implements FileEncoder {

private Charset charset;
	
	private EncodingDao encodingDao;
	
	public void encode(String text) {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				"spring-context.xml");
		encodingDao = (EncodingDao) context.getBean("encodingDao");
		charset = Charset.forName("unicode");
		
		encodingDao.writeToFileSystem(text, charset);
	}

}
